package com.banyuan.controller;

import com.banyuan.domain.User;
import com.banyuan.service.IUserService;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;

import java.util.List;

/**
 * @author yzt
 */
@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    private IUserService userService;

    @RequestMapping("/list")
    @ResponseBody  // 有这个注解，会自动返回给前段json对象
    public PageInfo<User> list(@RequestParam(value = "curr",defaultValue = "1") Integer curr,
                               @RequestParam(value = "size",defaultValue = "5") Integer size) {
        PageInfo<User> userList = userService.findAll(curr, size);
        return userList;  // 返回json对象
    }

}
